#pragma once

#include <Engine/IMeshObject.h>
#include <Engine/Renderer/Shaders/Constants.h>

namespace fastbird
{
	class MeshObject : public IMeshObject
	{
	public:
		MeshObject();
		virtual ~MeshObject();
		
		//------------------------------------------------------------------------
		// IObject
		//------------------------------------------------------------------------
		virtual void PreRender();
		virtual void Render();		
		virtual void PostRender();

		//------------------------------------------------------------------------
		// IMeshObject
		//------------------------------------------------------------------------
		virtual IObject* Clone() const;
		virtual bool LoadOgreMesh(const char* filename);
		virtual void ClearMeshData();
		virtual void StartModification();
		virtual void AddTriangle(const Vec3& pos0, const Vec3& pos1, const Vec3& pos2);
		virtual void AddQuad(const Vec3 pos[4], const Vec3 normal[4]);
		virtual void AddQuad(const Vec3 pos[4], const Vec3 normal[4], const Vec2 uv[4]);
		virtual void SetPositions(const Vec3* p, size_t numVertices);
		virtual void SetNormals(const Vec3* n, size_t numNormals);
		virtual void SetUVs(const Vec2* uvs, size_t numUVs);
		virtual void SetIndices(const UINT* indices, size_t numIndices);
		virtual void SetIndices(const USHORT* indices, size_t numIndices);
		virtual Vec3* GetVertices(size_t& outNumVertices);
		virtual void EndModification(bool keepMeshData);
		virtual void SetTopology(PRIMITIVE_TOPOLOGY topology);
		virtual PRIMITIVE_TOPOLOGY GetTopology();
		virtual void SetMaterial(const char* name);

	private:
		PRIMITIVE_TOPOLOGY mTopology;
		OBJECT_CONSTANTS mObjectConstants;
		SmartPtr<IVertexBuffer> mVBNormal;
		SmartPtr<IVertexBuffer> mVBUV;
		std::vector<Vec3> mPositions;
		std::vector<Vec3> mNormals;
		std::vector<Vec2> mUVs;	
	};
}